#!/usr/bin/python3
# -*- coding: utf-8 -*-

# import numpy as np
# import matplotlib.pyplot as plt


#折线图
# x = np.linspace(0, 2, 100)

# plt.plot(x, x, label='linear')
# plt.plot(x, x**2, label='quadratic')
# plt.plot(x, x**3, label='cubic')

# plt.xlabel('x label')
# plt.ylabel('y label')

# plt.title("Simple Plot")
# plt.legend()
# plt.show()


#柱状图
# size = 5
# a = np.random.random(size)
# b = np.random.random(size)
# c = np.random.random(size)

# x = np.arange(size)

# plt.bar(x, a, width=0.5, label='a', fc='r')
# plt.bar(x, b, bottom=a, width=0.5, label='b', fc='g')
# plt.bar(x, c, bottom=a+b, width=0.5, label='c', fc='b')

# plt.ylim(0, 2.5)
# plt.legend()
# plt.grid(True)
# plt.show()

 
# pyecharts
# from pyecharts.charts import Bar, Page
# from pyecharts import options as opts
 
# x = [ 'python数据可视化库 a1','python数据可视化库 b1','python数据可视化库 c1' ]
# y1 = [ 1140,520,270 ]
# y2 = [1000,300,500]
 
# bar = Bar()
#设置x轴
# bar.add_xaxis(xaxis_data=x)
#设置y轴
# bar.add_yaxis(series_name='平台A',y_axis=y1)
# bar.add_yaxis(series_name='平台B',y_axis=y2)
# bar.set_global_opts(title_opts=opts.TitleOpts(title='天猫不同平台得到销售数量'))
 
#生成html文件
# bar.render(path='first_bar.html')

#连漪散点图
# from pyecharts import options as opts
# from pyecharts.charts import EffectScatter
# from pyecharts.faker import Faker
# from pyecharts.globals import SymbolType

# c = (
#     EffectScatter()
#     .add_xaxis(Faker.choose())
#     .add_yaxis("", Faker.values(), symbol=SymbolType.ARROW)
#     .set_global_opts(title_opts=opts.TitleOpts(title="EffectScatter-不同Symbol"))
#     .render("effectscatter_symbol.html")
# )

#3D折线图
import math

import pyecharts.options as opts
from pyecharts.charts import Line3D

week_en = "Saturday Friday Thursday Wednesday Tuesday Monday Sunday".split()
clock = (
    "12a 1a 2a 3a 4a 5a 6a 7a 8a 9a 10a 11a 12p "
    "1p 2p 3p 4p 5p 6p 7p 8p 9p 10p 11p".split()
)

data = []
for t in range(0, 25000):
    _t = t / 1000
    x = (1 + 0.25 * math.cos(75 * _t)) * math.cos(_t)
    y = (1 + 0.25 * math.cos(75 * _t)) * math.sin(_t)
    z = _t + 2.0 * math.sin(75 * _t)
    data.append([x, y, z])

(
    Line3D()
    .add(
        "",
        data,
        xaxis3d_opts=opts.Axis3DOpts(data=clock, type_="value"),
        yaxis3d_opts=opts.Axis3DOpts(data=week_en, type_="value"),
        grid3d_opts=opts.Grid3DOpts(width=100, height=100, depth=100),
    )
    .set_global_opts(
        visualmap_opts=opts.VisualMapOpts(
            dimension=2,
            max_=30,
            min_=0,
            range_color=[
                "#313695",
                "#4575b4",
                "#74add1",
                "#abd9e9",
                "#e0f3f8",
                "#ffffbf",
                "#fee090",
                "#fdae61",
                "#f46d43",
                "#d73027",
                "#a50026",
            ],
        )
    )
    .render("line3d_rectangular_projection.html")
)